package com.xfs.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author dwj
 * @Date 2021-10-21 20:16
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    @Qualifier(value = "loginInterceptor")
    private HandlerInterceptor handlerInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(handlerInterceptor);

        registration.excludePathPatterns(
                "/login",               // 登录页面的请求
                "/welcome",             // 欢迎页的请求
                "emp/empList",          // 放行首页
                "/captcha",             // 验证码的请求
                "/user/login",           // 登录跳转的请求
                "/user/loginout",        // 退出登录的请求
                "/layui/**",            // layui的模板
                "/lib/**"               // 静态资源的请求
//                "/webjars/**"           // 自定义jquery的请求
        );
    }
}
